package com.woniuxy.config.route;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 马宇航
 * @do:路由模式配置，解决个性化记忆（异步），抖音 经常刷的视频，会把视频类别推送出去。
 * 1. 抖音类别队列
 * 2. 抖音历史记录队列
 * @DateTime: 25/09/01/星期一 10:25
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class RouteMQConfig {
    @Bean
    public Queue queue1(){
        return new Queue("douyin.category");
    }
    @Bean
    public Queue queue2(){
        return new Queue("douyin.history");
    }
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("douyin.exchange");
    }
    //绑定队列和交换机
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(queue1()).to(directExchange()).with("category");
    }
    @Bean
    public Binding binding2(){
        return BindingBuilder.bind(queue2()).to(directExchange()).with("history");
    }
    @Bean
    public Binding binding3(){
        return BindingBuilder.bind(queue2()).to(directExchange()).with("category");
    }
}
